// pages/progress/progress.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    info:{},
    dis:false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  gotoHomePage: function () {
    var that = this;
    var pages = getCurrentPages() //获取加载的页面

    var currentPage = pages[pages.length - 2] //获取当前页面的对象

    var url = currentPage.route //当前页面url;
    if (currentPage == 'pages/order_detail/order_detail') {
      wx.reLaunch({
        url: '../myOrder/myOrder'
      })
    }

  },
  onLoad: function (options) {
    var that = this;
    console.log(options)
    wx.request({
      url: 'https://rt.gzziyu.com//mobile/ziyu.php?Action=tuihuodetail',
      data:{
        orderid:options.id
      },
      success:function(res){
        console.log(res)
        var bool = res.data.orderzt==1?true:false
        that.setData({
          info:res.data,
          id:options.id,
          dis:bool
        })
      }
    })
    wx.request({
      url: 'https://rt.gzziyu.com/mobile/ny_flow_cart.php?action=get_shipping',
      data: {
        orderid: options.id
      },
      success: function (res) {
        console.log(res)
      }
    })
  },
  sure:function(){
    var that = this;
    wx.request({
      url: app.globalData.url+'ziyu.php?Action=huanhuozt',
      data:{
        orderid:that.data.id,
        openid:app.globalData.opid
      },
      success:function(res){
        if(res.data.success == 1){
          wx.showToast({
            title: '提交成功',
            icon: 'success',
            mask: true,
          })
          that.setData({
            dis:true
          })
         setTimeout(function(){
           wx.navigateBack()
         },1500)
        }

      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
   
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
    this.gotoHomePage()
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})